package com.navid.trafalgar.games;

import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.system.AppSettings;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;

/**
 *
 */
public class MyStartScreen extends AbstractAppState implements ScreenController {

    private Nifty nifty;
    private Application app;
    private Screen screen;
    private final AppSettings settings;

    MyStartScreen(AppSettings settings, Application app) {
        this.settings = settings;
        this.app = app;
    }

    public void startGame(String nextScreen) {
        nifty.gotoScreen(nextScreen);  
    }

    public void quitGame() {
        app.stop();
    }

    public String getPlayerName() {
        return System.getProperty("user.name");
    }

    /**
     * Nifty GUI ScreenControl methods
     */
    public void bind(Nifty nifty, Screen screen) {
        this.nifty = nifty;
        this.screen = screen;
    }

    public void onStartScreen() {
        new com.navid.trafalgar.mod.windtunnel.InterfaceGenerator(nifty, screen, settings, app).generate();
        new com.navid.trafalgar.mod.counterclock.InterfaceGenerator(nifty, screen, settings, app).generate();
    }

    public void onEndScreen() {
    }

    /**
     * jME3 AppState methods
     */
    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        this.app = app;
    }

    @Override
    public void update(float tpf) {
    }
}
